package L1;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class _071 {
    /**
     *  前世档案
     */
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String[] s = reader.readLine().split(" ");
        int N = Integer.valueOf(s[0]);
        int M = Integer.valueOf(s[1]);
        for (int i=0;i<M;i++){
            String line = reader.readLine();
            int sum = 1;
            for (int j=0;j<N;j++){
                if (line.charAt(j)=='y'){
                    sum=sum*2;
                }else {
                    sum=sum*2+1;
                }
            }
            System.out.println(sum-(int)Math.pow(2,N)+1);
        }
    }
}
